package com.hanoi.wiki.model.json;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.codehaus.jackson.map.annotate.JsonSerialize;

import com.hanoi.wiki.common.DateSerializer;
import com.hanoi.wiki.model.Places;
import com.hanoi.wiki.model.PlacesInQueued;
import com.hanoi.wiki.model.Rates;

public class RatesJson extends BaseJsonObject implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private int id;
	private int noOfRate;
	private Date updateTime;
	private String note;
	private int status;
	private List<Integer> places;
	private List<Integer> placesInQueueds;
	
	public RatesJson() {
		places = new ArrayList<Integer>();
		placesInQueueds = new ArrayList<Integer>();
	}
	
	public RatesJson(Rates rates) {
		this();
		if(rates != null) {
			this.id = rates.getId();
			this.noOfRate = rates.getNoOfRate();
			this.updateTime = rates.getUpdateTime();
			this.note = rates.getNote();
			this.status = rates.getStatus();
			
			for(Places place : rates.getPlaces()) {
				if(place != null) {
					places.add(place.getId());
				}
			}
			
			for(PlacesInQueued inQueued : rates.getPlacesInQueueds()) {
				if(inQueued != null) {
					placesInQueueds.add(inQueued.getId());
				}
			}
		}
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getNoOfRate() {
		return noOfRate;
	}

	public void setNoOfRate(int noOfRate) {
		this.noOfRate = noOfRate;
	}

	@JsonSerialize(using=DateSerializer.class)
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public List<Integer> getPlaces() {
		return places;
	}

	public void setPlaces(List<Integer> places) {
		this.places = places;
	}

	public List<Integer> getPlacesInQueueds() {
		return placesInQueueds;
	}

	public void setPlacesInQueueds(List<Integer> placesInQueueds) {
		this.placesInQueueds = placesInQueueds;
	}
	
	
}
